<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page session="true"%>
<%@page import="java.util.List, com.webapp.model.AdvertisementModel, com.webapp.model.Advertisement, com.webapp.model.Person,com.webapp.model.User,com.webapp.model.Manager,com.webapp.model.Employee"%>
<% 
	Person user = (Person)session.getAttribute("UserObject");
	User myUser = null;
	Manager manager = null;
	Employee employee = null;
		if( user != null) {
			if(user.getType().equals("user")) {
				myUser = (User)user;
			} else if (user.getType().equals("manager")) {
				manager = (Manager)user;
			} else {
				employee = (Employee)user;
			}
	}
		
	AdvertisementModel am = new AdvertisementModel();
	List ads = am.getAllAdvertisements();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
	<link href='http://fonts.googleapis.com/css?family=Rammetto+One' rel='stylesheet' type='text/css'>
	<link href='styles/default.css' rel='stylesheet' type='text/css'>
	<script src="https://www.google.com/jsapi?key=ABQIAAAA88Sobj6WnqBu9ty4mtFw7xS1fIpZt9juFHGOnRu1eLNWjlUeZhSXHaCrXiWZNOqv1IE1q-dHiHfaYw" type="text/javascript"></script>
   	<script language="Javascript" type="text/javascript">
    		//<![CDATA[
		google.load("jquery", "1.6.4", {uncompressed:true});
		google.load("jqueryui", "1.8.16", {uncompressed:true});			
    		function OnLoad() {
			$(document).ready(function() {
				$("#social_holder1").mouseenter(function () {
      					$(this).effect("bounce", { times:1 }, 400);
				});
				
				$("#social_holder2").mouseenter(function () {
      					$(this).effect("bounce", { times:1 }, 400);
				});
				
				$("#social_holder3").mouseenter(function () {
      					$(this).effect("bounce", { times:1 }, 400);
				});
			});
		}
    		google.setOnLoadCallback(OnLoad);
    		//]]>
    	</script>
    	
</head>
<body>
<div id="wrapper">
<div id="top_site">
	<div id="logo_holder">
		<div id="logo">
			<h1>MooTalk<br/><span style="font-size:13px;">The Intelligent Herd</span></h1>
		</div>
		<% if ( (user != null) && (user.getType().toLowerCase().equals("user"))) { %>
		<div id="social_bar">
			<a <%if (user == null) { %> href="Login.jsp" <% } else { %> href="GetAllPost.do"<% }%>class="social_link"><div id="social_holder1"><img src="images/barn.png"/><br/>The Barnyard</div></a>
			<a <%if (user == null) { %> href="Login.jsp" <% } else { %> href="Circles.do"<% }%>class="social_link"><div id="social_holder2"><img src="images/fence.png"/><br/>Your Fences</div></a>
			<a <%if (user == null) { %> href="Login.jsp" <% } else { %> href="GetAllPost.do"<% }%>class="social_link"><div id="social_holder3"><img src="images/cow.png"/><br/>	
			<% if ( user == null) { %>Account<% } else { %><%=user.getFirstName()%><% } %></div></a>
		</div>
		<% }  %>
	</div>
</div>
	
<div id="siteContent">
	<div id="navbar">
		<% if( user == null) { %>
		<div id="link_holder">
			<a href="Register.jsp" class="navlink">New User?</a>
			<a href="Login.jsp" class="navlink">Login</a>
		</div>
		<% } else if ( user.getType().equals("manager")) { %>
		<div id="link_holder">
			<a href="ManagerLanding.jsp" class="navlink">Manage</a>
			<a href="Logout.do" class="navlink">Logout</a>
		</div>
		<% } else if ( user.getType().equals("employee")) { %>
		<div id="link_holder">
			<a href="EmployeeLanding.jsp" class="navlink">Manage</a>
			<a href="Logout.do" class="navlink">Logout</a>
		</div>
		<% }  else { %>
		<div id="link_holder">
			<a href="MessageRecieved.do" class="navlink">Your Messages</a>
			<a href="ItemsCustomer.do?CUSTID=<%=myUser.getUserId()%>" class="navlink">Suggested Items</a>
			<a href="Logout.do" class="navlink">Logout</a>
		</div>
		<% }  %>
		<div id="feed_holder">
			<a href="pdf/MootalkFINAL.pdf" style="color:orange; float: right; padding: 5px; margin-right: 10px;">Need Help?</a>
		</div>
	</div>
	
	<div id="advertisments">
	
		<% 
			if( user != null ) { %>
				<%
				if((ads != null) && (user.getType().toLowerCase().equals("user"))) {
					int get1AD = new Double(Math.random() * ads.size()).intValue();
					int get2AD = new Double(Math.random() * ads.size()).intValue();
					Advertisement one = (Advertisement)ads.get(get1AD);
					Advertisement two = (Advertisement)ads.get(get2AD);
					%>
					<h2>Ads</h2>
					<div id="leftAd">
						<a href="AdClick.do?ad=<%=two.getAdvertisementId()%>">BUY NOW</a><br/><%=one.getItemName()%><br/><%=one.getContent()%>
					</div>
					<div id="rightAd">
						<a href="AdClick.do?ad=<%=two.getAdvertisementId()%>">BUY NOW</a><br/><%=two.getItemName()%><br/><%=two.getContent()%>
					</div>
			<%  } } %>
	</div>
	<div id="holder">